package com.xyzq.cgate.admin.wrapper;

import com.xyzq.cgate.common.entity.Plugin;
import com.xyzq.cgate.common.enums.PluginRoleEnum;
import com.xyzq.cgate.common.enums.OpenStateEnum;

/**
 * @Description:
 * @author chenchen
 * @date 2019/6/10 15:18
 */
public class PluginWrapper {

    public final static Plugin wrapper(Plugin plugin) {
        if(PluginRoleEnum.SYSTEM.getCode().equals(plugin.getRole())) {
            plugin.setRoleContent(PluginRoleEnum.SYSTEM.getName());
        } else {
            plugin.setRoleContent(PluginRoleEnum.USER.getName());
        }

        if(OpenStateEnum.OPEN.getCode().equals(plugin.getEnabled())) {
            plugin.setEnabledContent(OpenStateEnum.OPEN.isOpen());
        } else {
            plugin.setEnabledContent(OpenStateEnum.CLOSE.isOpen());
        }
        return plugin;
    }
}
